package com.joyintech.socket;

import java.io.*;
import java.net.Socket;

public class SimpleClient {
    public static void main(String[] args) {
        System.out.println("执行程序");
        String host = "47.116.19.16"; // 服务器的地址
        int port = 8000; // 服务器的端口号
        try (Socket socket = new Socket(host, port)) { // 连接到服务器
            OutputStream output = socket.getOutputStream();
            PrintWriter writer = new PrintWriter(output, true);
            InputStream input = socket.getInputStream();
            BufferedReader reader = new BufferedReader(new InputStreamReader(input));

            writer.println("Hello, Server!"); // 发送数据到服务器
            String response = reader.readLine(); // 读取服务器的响应
            System.out.println("Server response: " + response);
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}
